package ooday04homework;

public class PolymorphicDemo {
    public static void main(String[] args) {
        Animal[] animals =new Animal[5];
        animals[0] = new Dog("小黑",2,"黑");
        animals[1] = new Dog("小灰",2,"灰");
        animals[2] = new Fish("小金",2,"金");
        animals[3] = new Fish("小蓝",2,"蓝");
        animals[4] = new Chick("小黄",2,"黄");
        for (int i=0;i< animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog ){
                Dog o1=(Dog) animals[i];
                o1.LookHome();
            }else if (animals[i] instanceof Chick){
                Chick o2=(Chick) animals[i];
                o2.layEggs();
            if (animals[i] instanceof Swim){
                Swim o3 = (Swim) animals[i];
                o3.swim();
            }
            }
        }
        Master master = new Master();
        Dog dog = new Dog("灰太狼",2,"灰");
        Fish fish =new Fish("泡泡",3,"金");
        Chick chick = new Chick("ikun",2,"灰");

        master.feed(dog);
        master.feed(fish);
        master.feed(chick);
    }
}
